
expstack = ""
evalstack = ""

def cmpopstack(op):
	if op in ["+","-"] and expstack[-1] in ["*","/"]:
		return False
	else:
		return True

expr = "a+b/c+5*(6+a)"

for token in expr:
	expstack.append(token)
	if token == "(" :
		expstack.push(token)
	if token == ")" :
		while len(expstack) !=0 and expstack[-1] is not "(":
			exprelemt = expstack.pop()
			evalstack.append(exprelemt)
		expstack.pop() #Pop the left parenthesis from the stack and discard it 
		
	if token in ["+","-","*","/"]:
		if len(expstack) = 0 or expstack[-1] == "(" :
			expstack.append(token)
		else:
			while len(expstack) != 0 and expstack[-1] != '(' and cmpopstack(token) :
				exprelemt = expstack.pop()
				evalstack.append(exprelemt)
			expstack.append(token)

while len(expstack) != 0:
	exprelemt = expstack.pop()
	evalstack.append(exprelemt)